package top.yekongle.excel.controller;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import top.yekongle.excel.entity.User;
import top.yekongle.excel.service.UserService;
import top.yekongle.excel.util.ExcelUtil;

/**
 * <pre>
* &#64;Description: 
* &#64;Author: Yekongle 
* &#64;Date: Apr 1, 2020
 * </pre>
 */

@RestController
@RequestMapping("/excel/export")
public class ExcelExportController {
	@Autowired
	private UserService userService;

	@GetMapping("/exportExcel")
	public void export(HttpServletResponse response) {
		System.out.println(1);
		// 模拟从数据库获取需要导出的数据
		List<User> personList = userService.findAll();
		// 导出操作
		ExcelUtil.exportExcel(personList, "easypoi导出功能测试", "export_1", User.class, "export_test.xls", response);

	}
}
